<template>
    <div class="rootMain">
        <el-form label-position="right" label-width="150px">
            <el-form-item label="收入类型">
                <el-select
                    v-model="incomeIndex"
                    placeholder="请选择"
                    @change="incomeChange"
                >
                    <el-option
                        v-for="(item, index) in incomePicker"
                        :key="index"
                        :label="item.name"
                        :value="index"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item v-if="personalShow" label="税前年收入(元)">
                <el-input v-model="taxIncome"></el-input>
            </el-form-item>
            <el-form-item v-if="personalShow" label="社会保险费用（年）">
                <el-input v-model="socialCost"></el-input>
            </el-form-item>
            <el-form-item v-if="personalShow" label="个人所得税免征税额">
                {{ fiexdBands.toFixed(2) }}
            </el-form-item>
            <div v-if="personalShow">
                <el-form-item label="">
                    <el-checkbox
                        v-model="childBox[0].checked"
                        @change="childCheck"
                    >
                        子女教育(含婴幼儿专项附加扣除)
                    </el-checkbox>
                </el-form-item>
                <el-form-item v-if="childShow" label="子女个数">
                    <el-select
                        v-model="childIndex"
                        placeholder="请选择"
                        @change="childChange"
                    >
                        <el-option
                            v-for="(item, index) in childNum"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="childShow" label="扣除方式">
                    <el-select
                        v-model="deductIndex"
                        placeholder="请选择"
                        @change="deductChange"
                    >
                        <el-option
                            v-for="(item, index) in deductWay"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="childShow" label="扣除额">
                    {{ childBands.toFixed(2) }}
                </el-form-item>

                <el-form-item label="">
                    <el-checkbox
                        v-model="educationBox[0].checked"
                        @change="educationCheck"
                    >
                        继续教育(专项附加扣除)
                    </el-checkbox>
                </el-form-item>
                <el-form-item v-if="educationShow" label="教育类型">
                    <el-select
                        v-model="educationIndex"
                        placeholder="请选择"
                        @change="educationChange"
                    >
                        <el-option
                            v-for="(item, index) in educationType"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="educationShow" label="扣除额">
                    {{ educationBands.toFixed(2) }}
                </el-form-item>

                <el-form-item label="">
                    <el-checkbox
                        v-model="illnessBox[0].checked"
                        @change="illnessCheck"
                    >
                        大病医疗(专项附加扣除)
                    </el-checkbox>
                </el-form-item>
                <el-form-item v-if="illnessShow" label="扣除额">
                    <el-input v-model="illnessBands"></el-input>
                </el-form-item>

                <el-form-item label="">
                    <el-checkbox
                        v-model="homeBox[0].checked"
                        @change="homeCheck"
                    >
                        居住扣除(专项附加扣除)
                    </el-checkbox>
                </el-form-item>
                <el-form-item v-if="homeShow" label="居住类型">
                    <el-select
                        v-model="homeIndex"
                        placeholder="请选择"
                        @change="homeChange"
                    >
                        <el-option
                            v-for="(item, index) in homeType"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="homeShow && !rentShow" label="扣除额">
                    {{ homeBands.toFixed(2) }}
                </el-form-item>
                <el-form-item v-if="homeShow && rentShow" label="扣除额">
                    <el-select
                        v-model="rentIndex"
                        placeholder="请选择"
                        @change="rentChange"
                    >
                        <el-option
                            v-for="(item, index) in rentType"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="">
                    <el-checkbox v-model="oldBox[0].checked" @change="oldCheck">
                        赡养老人(专项附加扣除)
                    </el-checkbox>
                </el-form-item>
                <el-form-item v-if="oldShow" label="扣除方式">
                    <el-select
                        v-model="oldIndex"
                        placeholder="请选择"
                        @change="oldChange"
                    >
                        <el-option
                            v-for="(item, index) in oldWay"
                            :key="index"
                            :label="item"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="oldShow && oldChildShow" label="子女个数">
                    <el-select
                        v-model="oldChildIndex"
                        placeholder="请选择"
                        @change="oldChildChange"
                    >
                        <el-option
                            v-for="(item, index) in oldChildNum"
                            :key="index"
                            :label="item.num"
                            :value="index"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item v-if="oldShow" label="扣除额">
                    {{ oldBands.toFixed(2) }}
                </el-form-item>
            </div>

            <el-form-item v-if="manageShow" label="收入金额">
                <el-input v-model="incomePrice" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="manageShow" label="扣除支出">
                <el-input v-model="deductExpend" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="manageShow" label="月减除费用">
                <div>{{ monthBands.toFixed(2) }}</div>
            </el-form-item>
            <el-form-item v-if="manageShow" label="经营时间">
                <el-select
                    v-model="manageIndex"
                    placeholder="请选择"
                    @change="manageChange"
                >
                    <el-option
                        v-for="(item, index) in manageTime"
                        :key="index"
                        :label="item"
                        :value="index"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item v-if="labourShow" label="收入金额">
                <el-input v-model="labourPrice" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="remunerationShow" label="收入金额">
                <el-input
                    v-model="remunerationPrice"
                    placeholder="0"
                ></el-input>
            </el-form-item>
            <el-form-item v-if="privilegeShow" label="收入金额">
                <el-input v-model="privilegePrice" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="leaseShow" label="收入金额">
                <el-input v-model="leasePrice" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="leaseShow" label="允许扣除的税费">
                <el-input v-model="leaseDeduct" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="leaseShow" label="减除费用">
                <el-input
                    v-model="repairPrice"
                    placeholder="0"
                    disabled
                ></el-input>
            </el-form-item>
            <el-form-item v-if="leaseShow" label="适用税率">
                <el-select
                    v-model="taxIndex"
                    placeholder="请选择"
                    @change="taxChange"
                >
                    <el-option
                        v-for="(item, index) in taxPicker"
                        :key="index"
                        :label="item"
                        :value="index"
                    >
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item v-if="makeOverShow" label="收入金额">
                <el-input v-model="makeOverPrice" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="makeOverShow" label="财产原值">
                <el-input v-model="originalValue" placeholder="0"></el-input>
            </el-form-item>
            <el-form-item v-if="makeOverShow" label="合理费用">
                <el-input v-model="reasonableExpend" placeholder="0"></el-input>
            </el-form-item>

            <el-form-item v-if="accidentShow" label="收入金额">
                <el-input v-model="accidentPrice" placeholder="0"></el-input>
            </el-form-item>
        </el-form>

        <div class="but">
            <el-button @click="resetBtn">重置</el-button>
            <el-button type="primary" @click="countBtn">计算</el-button>
        </div>

        <div v-if="resultShow" class="result">
            <el-descriptions title="计算结果：" :column="1">
                <el-descriptions-item label="应缴税款(元)">
                    {{ shouldTax.toFixed(2) }}
                </el-descriptions-item>
                <el-descriptions-item label="税后收入(元)">
                    {{ taxOutcome.toFixed(2) }}
                </el-descriptions-item>
                <el-descriptions-item label="应纳税所得额(元)">
                    {{ shouldIncome.toFixed(2) }}
                </el-descriptions-item>
                <el-descriptions-item label="适用税率(元)">
                    {{ applyTax }}
                </el-descriptions-item>
                <el-descriptions-item
                    v-if="
                        !remunerationShow &&
                        !privilegeShow &&
                        !leaseShow &&
                        !makeOverShow &&
                        !accidentShow
                    "
                    label="速算扣除数(元)"
                >
                    {{ quickCount.toFixed(2) }}
                </el-descriptions-item>
                <el-descriptions-item
                    v-if="labourShow || remunerationShow || privilegeShow"
                    label="减除费用(元)"
                >
                    {{ expendPrice.toFixed(2) }}
                </el-descriptions-item>
            </el-descriptions>
        </div>
    </div>
</template>

<script>
import moment from "moment";
export default {
    name: "personalTax",
    props: {
        item: {
            type: Object,
            default: () => {
                return {};
            },
        },
    },
    data() {
        return {
            //收入类型选择
            incomeIndex: 0,
            incomePicker: [
                {
                    type: 0,
                    name: "综合所得",
                },
                {
                    type: 1,
                    name: "工资、薪金所得",
                },
                {
                    type: 2,
                    name: "经营所得",
                },
                {
                    type: 3,
                    name: "劳务报酬所得",
                },
                {
                    type: 4,
                    name: "稿酬所得",
                },
                {
                    type: 5,
                    name: "特许权使用费所得",
                },
                {
                    type: 6,
                    name: "财产租赁所得",
                },
                {
                    type: 7,
                    name: "财产转让所得",
                },
                {
                    type: 8,
                    name: "偶然所得",
                },
            ],
            taxIncome: "", //税前收入,
            socialCost: "", //社会保险费用
            fiexdBands: 60000, //免征税额
            resultShow: false,

            //子女教育专项附加扣除
            childBox: [
                {
                    value: "1",
                    checked: false,
                },
            ],
            childIndex: 0,
            childNum: [1, 2, 3, 4, 5, 6, 7, 8, 9],
            deductIndex: 0,
            deductWay: ["单独承担100%扣除", "夫妻双方50%扣除"],
            childBands: 24000,
            childShow: false,

            //继续教育专项附加扣除
            educationBox: [
                {
                    value: "1",
                    checked: false,
                },
            ],
            educationShow: false,
            educationIndex: 0,
            educationType: ["学历教育", "职业资格教育"],
            educationBands: 4800,

            //大病医疗专项附加扣除
            illnessBox: [
                {
                    value: "1",
                    checked: false,
                },
            ],
            illnessShow: false,
            illnessBands: "",

            //居住专项附加扣除、
            homeBox: [
                {
                    value: "1",
                    checked: false,
                },
            ],
            homeShow: false,
            homeIndex: 0,
            homeType: ["首房贷款", "住房租金"],
            homeBands: 12000,
            rentIndex: 0,
            rentType: [9600, 13200, 18000],
            rentShow: false,

            //赡养老人专项附加扣除
            oldBox: [
                {
                    value: "1",
                    checked: false,
                },
            ],
            oldShow: false,
            oldIndex: 0,
            oldWay: ["独生子女", "非独生子女"],
            oldBands: 36000,
            oldChildIndex: 0,
            oldChildNum: [
                {
                    id: 1,
                    num: 2,
                },
                {
                    id: 2,
                    num: 3,
                },
                {
                    id: 3,
                    num: 4,
                },
                {
                    id: 4,
                    num: 5,
                },
                {
                    id: 5,
                    num: 6,
                },
                {
                    id: 6,
                    num: 7,
                },
                {
                    id: 7,
                    num: 8,
                },
                {
                    id: 8,
                    num: 9,
                },
            ],
            oldChildShow: false,

            //最终结果
            shouldTax: 0, //应缴税款
            taxOutcome: 0, //税后收入
            shouldIncome: 0, //应纳税所得额
            applyTax: 0, //适用税率
            quickCount: 0, //速算扣除数
            personalShow: true,

            //经营所得
            manageShow: false,
            incomePrice: "",
            deductExpend: "",
            monthBands: 5000,
            manageIndex: "",
            manageTime: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],

            //劳务报酬所得
            labourShow: false,
            labourPrice: "",
            expendPrice: 0,

            //稿酬所得
            remunerationShow: false,
            remunerationPrice: "",

            //特权使用费
            privilegeShow: false,
            privilegePrice: "",

            //财产租赁所得
            taxPicker: ["20%", "10%"],
            taxIndex: 0,
            leasePrice: "",
            leaseDeduct: "",
            repairPrice: "",
            leaseShow: false,

            //财产转让所得
            makeOverPrice: "",
            originalValue: "",
            reasonableExpend: "",
            makeOverShow: false,

            //偶然所得
            accidentPrice: "",
            accidentShow: false,
        };
    },
    watch: {
        childDeduct(val) {
            if (val.deductIndex != 0) {
                this.childBands = (24000 * (Number(val.childIndex) + 1)) / 2;
            } else {
                this.childBands = 24000 * (Number(val.childIndex) + 1);
            }
        },
    },
    created() {},
    mounted() {},
    computed: {
        childDeduct() {
            const { childIndex, deductIndex } = this;
            return {
                childIndex,
                deductIndex,
            };
        },
    },
    methods: {
        //收入方式选择
        incomeChange(index) {
            this.resultShow = false;
            this.incomeIndex = index;
            let val = index;
            if (val == 0 || val == 1) {
                this.personalShow = true;
                this.manageShow = false;
                this.labourShow = false;
                this.remunerationShow = false;
                this.privilegeShow = false;
                this.leaseShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 2) {
                this.manageShow = true;
                this.personalShow = false;
                this.labourShow = false;
                this.remunerationShow = false;
                this.privilegeShow = false;
                this.leaseShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 3) {
                this.labourShow = true;
                this.personalShow = false;
                this.manageShow = false;
                this.remunerationShow = false;
                this.privilegeShow = false;
                this.leaseShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 4) {
                this.remunerationShow = true;
                this.personalShow = false;
                this.manageShow = false;
                this.labourShow = false;
                this.privilegeShow = false;
                this.leaseShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 5) {
                this.privilegeShow = true;
                this.remunerationShow = false;
                this.personalShow = false;
                this.manageShow = false;
                this.labourShow = false;
                this.leaseShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 6) {
                this.leaseShow = true;
                this.privilegeShow = false;
                this.remunerationShow = false;
                this.personalShow = false;
                this.manageShow = false;
                this.labourShow = false;
                this.makeOverShow = false;
                this.accidentShow = false;
            } else if (val == 7) {
                this.makeOverShow = true;
                this.leaseShow = false;
                this.privilegeShow = false;
                this.remunerationShow = false;
                this.personalShow = false;
                this.manageShow = false;
                this.labourShow = false;
                this.accidentShow = false;
            } else if (val == 8) {
                this.accidentShow = true;
                this.makeOverShow = false;
                this.leaseShow = false;
                this.privilegeShow = false;
                this.remunerationShow = false;
                this.personalShow = false;
                this.manageShow = false;
                this.labourShow = false;
            }
        },

        childChange(index) {
            this.childIndex = index;
        },
        deductChange(index) {
            this.deductIndex = index;
        },

        childCheck(e) {
            this.childShow = e;
            var items = this.childBox,
                values = e;
            // this.childBox[0].checked = e;
            // for (var i = 0, lenI = items.length; i < lenI; ++i) {
            //     items[i].checked = false;
            //     for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
            //         if (items[i].value == values[j]) {
            //             items[i].checked = true;
            //             break;
            //         }
            //     }
            // }
            // console.log(this.childBox)

            // this.personalShowFalse();
        },

        personalShowFalse() {
            this.personalShow = false;
            this.$nextTick(() => {
                this.personalShow = true;
            });
        },

        //继续教育专项附加扣除
        educationCheck(e) {
            this.educationShow = e;

            var items = this.educationBox,
                values = e;
            // for (var i = 0, lenI = items.length; i < lenI; ++i) {
            //     items[i].checked = false;
            //     for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
            //         if (items[i].value == values[j]) {
            //             items[i].checked = true;
            //             break;
            //         }
            //     }
            // }
        },

        //大病医疗专项附加扣除
        illnessCheck(e) {
            this.illnessShow = e;
            var items = this.illnessBox,
                values = e;
            // for (var i = 0, lenI = items.length; i < lenI; ++i) {
            //     items[i].checked = false;
            //     for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
            //         if (items[i].value == values[j]) {
            //             items[i].checked = true;
            //             break;
            //         }
            //     }
            // }
        },

        message(m) {
            this.$message({
                message: m,
                type: "warning",
            });
        },

        educationChange(index) {
            this.educationIndex = index;
            if (index == 0) {
                this.educationBands = 4800;
            } else {
                this.educationBands = 3600;
            }
        },

        homeCheck(e) {
            this.homeShow = e;
            var items = this.homeBox,
                values = e;
            // for (var i = 0, lenI = items.length; i < lenI; ++i) {
            //     items[i].checked = false;
            //     for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
            //         if (items[i].value == values[j]) {
            //             items[i].checked = true;
            //             break;
            //         }
            //     }
            // }
        },

        //居住专项附加扣除
        homeChange(e) {
            this.homeIndex = e;
            if (e == 0) {
                this.rentShow = false;
            } else {
                this.rentShow = true;
            }
        },

        rentChange(e) {
            this.rentIndex = e;
        },

        //赡养老人专项附加扣除
        oldCheck(e) {
            this.oldShow = e;
            var items = this.oldBox,
                values = e;
            // for (var i = 0, lenI = items.length; i < lenI; ++i) {
            //     items[i].checked = false;
            //     for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
            //         if (items[i].value == values[j]) {
            //             items[i].checked = true;
            //             break;
            //         }
            //     }
            // }
        },

        oldChange(e) {
            this.oldIndex = e;
            if (e == 1) {
                this.oldChildShow = true;
                this.oldBands =
                    36000 / this.oldChildNum[this.oldChildIndex].num;
            } else {
                this.oldChildShow = false;
                this.oldBands = 36000;
            }
        },

        oldChildChange(e) {
            this.oldChildIndex = e;
            this.oldBands = 36000 / this.oldChildNum[this.oldChildIndex].num;
        },

        //经营所得
        manageChange(e) {
            this.manageIndex = e;
        },

        //财产租赁所得
        taxChange(e) {
            this.taxIndex = e;
        },

        //重置
        resetBtn() {
            this.resultShow = false;
            if (this.incomeIndex == 0 || this.incomeIndex == 1) {
                this.taxIncome = "";
                this.socialCost = "";
                this.childBox[0].checked = false;
                this.childShow = false;
                this.educationBox[0].checked = false;
                this.educationShow = false;
                this.illnessBox[0].checked = false;
                this.illnessShow = false;
                this.homeBox[0].checked = false;
                this.homeShow = false;
                this.oldBox[0].checked = false;
                this.oldShow = false;
            } else if (this.incomeIndex == 2) {
                this.incomePrice = "";
                this.deductExpend = "";
                this.manageIndex = "";
            } else if (this.incomeIndex == 3) {
                this.labourPrice = "";
            } else if (this.incomeIndex == 4) {
                this.remunerationPrice = "";
            } else if (this.incomeIndex == 5) {
                this.privilegePrice = "";
            } else if (this.incomeIndex == 6) {
                this.leasePrice = "";
                this.leaseDeduct = "";
                this.repairPrice = "";
                this.taxIndex = 0;
            } else if (this.incomeIndex == 7) {
                this.makeOverPrice = "";
                this.originalValue = "";
                this.reasonableExpend = "";
            } else if (this.incomeIndex == 8) {
                this.accidentPrice = "";
            }
        },

        //计算
        countBtn() {
            console.log(this.incomeIndex);

            if (this.incomeIndex == 0 || this.incomeIndex == 1) {
                console.log(this.incomeIndex);

                if (this.incomeIndex === "") {
                    this.message("请选择收入类型");
                    return;
                }
                if (this.taxIncome == "") {
                    this.message("请填写税前年收入");
                    return;
                }
                var childBands;
                var educationBands;
                var illnessBands;
                var homeBands;
                var oldBands;
                if (this.childShow) {
                    childBands = this.childBands;
                } else {
                    childBands = 0;
                }
                if (this.educationShow) {
                    educationBands = this.educationBands;
                } else {
                    educationBands = 0;
                }
                if (this.illnessShow) {
                    if (
                        this.illnessBands < 15000 ||
                        this.illnessBands > 80000
                    ) {
                        this.message("大病扣除需在规定范围之内");
                        return;
                    }
                    illnessBands = Number(this.illnessBands);
                } else {
                    illnessBands = 0;
                }
                if (this.homeShow) {
                    if (this.rentShow) {
                        homeBands = this.rentType[this.rentIndex];
                    } else {
                        homeBands = this.homeBands;
                    }
                } else {
                    homeBands = 0;
                }
                if (this.oldShow) {
                    oldBands = this.oldBands;
                } else {
                    oldBands = 0;
                }
                console.log(
                    childBands,
                    educationBands,
                    illnessBands,
                    homeBands,
                    oldBands
                );
                const finalPrice =
                    this.taxIncome -
                    this.socialCost -
                    childBands -
                    educationBands -
                    illnessBands -
                    homeBands -
                    oldBands -
                    60000;
                if (finalPrice <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                this.shouldIncome = finalPrice;
                if (0 < finalPrice && finalPrice <= 36000) {
                    const rate = finalPrice * 0.03;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 3 + "%";
                    this.quickCount = 0;
                } else if (36000 < finalPrice && finalPrice <= 144000) {
                    const rate = finalPrice * 0.1 - 2520;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 10 + "%";
                    this.quickCount = 2520;
                } else if (144000 < finalPrice && finalPrice <= 300000) {
                    const rate = finalPrice * 0.2 - 16920;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 20 + "%";
                    this.quickCount = 16920;
                } else if (300000 < finalPrice && finalPrice <= 420000) {
                    const rate = finalPrice * 0.25 - 31920;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 25 + "%";
                    this.quickCount = 31920;
                } else if (420000 < finalPrice && finalPrice <= 660000) {
                    const rate = finalPrice * 0.3 - 52920;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 30 + "%";
                    this.quickCount = 52920;
                } else if (660000 < finalPrice && finalPrice <= 960000) {
                    const rate = finalPrice * 0.35 - 85920;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 35 + "%";
                    this.quickCount = 85920;
                } else if (960000 < finalPrice) {
                    const rate = finalPrice * 0.45 - 181920;
                    this.shouldTax = rate;
                    this.taxOutcome = this.taxIncome - rate;
                    this.applyTax = 45 + "%";
                    this.quickCount = 181920;
                }
                this.resultShow = true;
            } else if (this.incomeIndex == 2) {
                if (this.incomePrice === "") {
                    this.message("请输入金额");
                    return;
                }
                if (this.manageIndex === "") {
                    this.message("请选择经营时间");
                    return;
                }
                const finalPrice =
                    this.incomePrice -
                    this.deductExpend -
                    (this.manageIndex + 1) * 5000;
                if (finalPrice <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                this.shouldIncome = finalPrice;
                if (0 < finalPrice && finalPrice <= 30000) {
                    const rate = finalPrice * 0.05;
                    this.shouldTax = rate;
                    this.taxOutcome = this.incomePrice - rate;
                    this.applyTax = 5 + "%";
                    this.quickCount = 0;
                } else if (30000 < finalPrice && finalPrice <= 90000) {
                    const rate = finalPrice * 0.1 - 1500;
                    this.shouldTax = rate;
                    this.taxOutcome = this.incomePrice - rate;
                    this.applyTax = 10 + "%";
                    this.quickCount = 1500;
                } else if (90000 < finalPrice && finalPrice <= 300000) {
                    const rate = finalPrice * 0.2 - 10500;
                    this.shouldTax = rate;
                    this.taxOutcome = this.incomePrice - rate;
                    this.applyTax = 20 + "%";
                    this.quickCount = 10500;
                } else if (300000 < finalPrice && finalPrice <= 500000) {
                    const rate = finalPrice * 0.3 - 40500;
                    this.shouldTax = rate;
                    this.taxOutcome = this.incomePrice - rate;
                    this.applyTax = 30 + "%";
                    this.quickCount = 40500;
                } else if (500000 < finalPrice) {
                    const rate = finalPrice * 0.35 - 65500;
                    this.shouldTax = rate;
                    this.taxOutcome = this.incomePrice - rate;
                    this.applyTax = 35 + "%";
                    this.quickCount = 65500;
                }
                this.resultShow = true;
            } else if (this.incomeIndex == 3) {
                if (this.labourPrice == "") {
                    this.message("请填写收入金额");
                    return;
                }
                if (this.labourPrice - 800 <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                var finalPrice;
                if (this.labourPrice > 800 && this.labourPrice <= 4000) {
                    finalPrice = this.labourPrice - 800;
                    this.expendPrice = 800;
                } else if (this.labourPrice > 4000) {
                    finalPrice = this.labourPrice - this.labourPrice * 0.2;
                    this.expendPrice = this.labourPrice * 0.2;
                }
                this.shouldIncome = finalPrice;
                if (0 < finalPrice && finalPrice <= 20000) {
                    const rate = finalPrice * 0.2;
                    this.shouldTax = rate;
                    this.taxOutcome = this.labourPrice - rate;
                    this.applyTax = 20 + "%";
                    this.quickCount = 0;
                } else if (20000 < finalPrice && finalPrice <= 50000) {
                    const rate = finalPrice * 0.3 - 2000;
                    this.shouldTax = rate;
                    this.taxOutcome = this.labourPrice - rate;
                    this.applyTax = 30 + "%";
                    this.quickCount = 2000;
                } else if (5000 < finalPrice) {
                    const rate = finalPrice * 0.4 - 2000;
                    this.shouldTax = rate;
                    this.taxOutcome = this.labourPrice - rate;
                    this.applyTax = 40 + "%";
                    this.quickCount = 7000;
                }
                this.resultShow = true;
            } else if (this.incomeIndex == 4) {
                var finalPrice;
                if (this.remunerationPrice == "") {
                    this.message("请填写收入金额");
                    return;
                }
                if (this.remunerationPrice - 800 <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                if (
                    this.remunerationPrice > 800 &&
                    this.remunerationPrice <= 4000
                ) {
                    finalPrice = this.remunerationPrice - 800;
                    this.expendPrice = 800;
                } else if (this.remunerationPrice > 4000) {
                    finalPrice =
                        this.remunerationPrice - this.remunerationPrice * 0.2;
                    this.expendPrice = this.remunerationPrice * 0.2;
                }
                if (finalPrice <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                this.shouldIncome = finalPrice;
                const rate = finalPrice * 0.14;
                this.shouldTax = rate;
                this.taxOutcome = this.remunerationPrice - rate;
                this.applyTax = 14 + "%";
                this.quickCount = 0;
                this.resultShow = true;
            } else if (this.incomeIndex == 5) {
                if (this.privilegePrice == "") {
                    this.message("请填写收入金额");
                    return;
                }
                if (this.privilegePrice - 800 <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }

                var finalPrice;
                if (this.privilegePrice > 800 && this.privilegePrice <= 4000) {
                    finalPrice = this.privilegePrice - 800;
                    this.expendPrice = 800;
                } else if (this.privilegePrice > 4000) {
                    finalPrice =
                        this.privilegePrice - this.privilegePrice * 0.2;
                    this.expendPrice = this.privilegePrice * 0.2;
                }
                if (finalPrice <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                this.shouldIncome = finalPrice;
                const rate = finalPrice * 0.2;
                this.shouldTax = rate;
                this.taxOutcome = this.privilegePrice - rate;
                this.applyTax = 20 + "%";
                this.quickCount = 0;
                this.resultShow = true;
            } else if (this.incomeIndex == 6) {
                // if (this.repairPrice > "800") {
                //     this.message("每次(月)修缮费用上限为800");
                //     return;
                // }
                if (this.leasePrice == "" || this.leasePrice == 0) {
                    this.message("请输入收入金额");
                    return;
                }
                if (this.leasePrice <= 800) {
                    this.message("您未达到纳税标准无需交税");
                    this.resultShow = false
                    return;
                }

                if (this.leasePrice - this.leaseDeduct <= 4000) {
                    this.repairPrice = 800;
                } else {
                    let price1 = (this.leasePrice - this.leaseDeduct) * 0.2;
                    this.repairPrice = parseFloat(price1.toFixed(2));
                }

                var price =
                    this.leasePrice - this.leaseDeduct - this.repairPrice;
                var tax;
                console.log(price);
                if (price <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    this.resultShow = false
                    return;
                }
                if (this.taxIndex == 0) {
                    tax = 0.2;
                } else {
                    tax = 0.1;
                }

                // if (price - 800 <= 0) {
                //     this.message("您未达到纳税标准无需交税");
                //     return;
                // }
                // if (price > 800 && price <= 4000) {
                //     finalPrice = price - 800;
                // } else if (price > 4000) {
                //     finalPrice = price - price * 0.2;
                // }
                // this.shouldIncome = finalPrice;
                // const rate = finalPrice * tax;
                // this.shouldTax = rate;
                // this.taxOutcome = this.leasePrice - rate;
                // this.applyTax = tax * 100 + "%";
                // this.resultShow = true;
                this.shouldTax = price * tax; //应缴税款
                this.shouldIncome = price; //应纳税所得额
                this.taxOutcome = this.leasePrice - price * tax; //税后收入
                this.applyTax = tax * 100 + "%"; //适用税率
                this.resultShow = true;
            } else if (this.incomeIndex == 7) {
                var price =
                    this.makeOverPrice -
                    this.originalValue -
                    this.reasonableExpend;
                if (price <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                const rate = price * 0.2;
                this.shouldIncome = price;
                this.shouldTax = rate;
                this.taxOutcome = this.makeOverPrice - rate;
                this.applyTax = 20 + "%";
                this.resultShow = true;
            } else if (this.incomeIndex == 8) {
                if (this.accidentPrice <= 0) {
                    this.message("您未达到纳税标准无需交税");
                    return;
                }
                const rate = this.accidentPrice * 0.2;
                this.shouldIncome = Number(this.accidentPrice);
                this.shouldTax = rate;
                this.taxOutcome = this.accidentPrice - rate;
                this.applyTax = 20 + "%";
                this.resultShow = true;
            }
        },
    },
};
</script>

<style lang="scss" scoped>
.rootMain {
    padding: 20px 22px;
}

.result {
    padding-top: 25px;
}
</style>
